package com.example.mine_platform.controller;

import com.example.mine_platform.commom.Result;
import com.example.mine_platform.pojo.dto.PwdDTO;
import com.example.mine_platform.service.CheckPwdService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@CrossOrigin(origins = "*")
public class HistoryPasswordController {
    @Resource
    CheckPwdService checkPwdService;
    @PutMapping("/user/changepwd")
    public Result updatePwd(@RequestBody PwdDTO pwdDTO){
        if(!checkPwdService.checkpwd1(pwdDTO.getPassword()))
            return Result.error("修改密码不符合要求");
        String message=checkPwdService.checkpwd2(pwdDTO);
        if(message.equals("密码修改成功"))
            return Result.success();
        else return Result.error(message);
    }
}
